//
//  FWShareObject.m
//  FWShare
//
//  Created by 范文青 on 14-6-14.
//  Copyright (c) 2014年 fwq. All rights reserved.
//

#import "FWShareObject.h"
#import "FWAuthViewController.h"
@interface FWShareObject()
{
}
@property (nonatomic,strong)FWAuthViewController  *authController;
@end
@implementation FWShareObject
- (instancetype)initWithPlatform:(NSString *)platform
{
    self = [super init];
    if (self) {
        _platform = platform;

    }
    return self;
}

- (void)auth:(UIViewController *)parentController success:(void(^)(FWAuthUser *,NSString *))success failed:(void(^)(NSError *,NSString *))failed canceled:(void(^)(NSString *))canceld
{
    self.authController = [[FWAuthViewController alloc] initWithPlatform:_platform];
    __block __weak FWAuthViewController *authController = _authController;
    
    [_authController setAuthSuccess:^(FWAuthUser *user, NSString *platform) {
        [authController dismissViewControllerAnimated:YES completion:nil];
        if (success) {
            success(user,platform);
        }
    }];
    [_authController setAuthCanceled:^(NSString *platform) {
        [authController dismissViewControllerAnimated:YES completion:nil];
        if (canceld) {
            canceld(platform);
        }
    }];
    [_authController setAuthFailed:^(NSError *error, NSString *platform) {
        [authController dismissViewControllerAnimated:YES completion:nil];
        if (failed) {
            failed(error,platform);
        }
    }];

    [authController setForceAuth:_forceAuth];
     [parentController presentViewController:_authController animated:YES completion:nil];
    [_authController auth];
}
- (void)share:(NSString *)content
{
    
}
- (void)share:(NSString *)content pic:(NSData *)pic
{
    
}
@end
